package com.example.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;


/**
 * @author: 21050134
 * @date: 2023/12/11 14:23
 * @description:
 */
@Slf4j
@WebFilter(filterName = "myFilter", urlPatterns = {"/**"})
@Component
public class MyFilter implements Filter {
	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		log.info("----------MyFilter---------");
		MyHttpServletRequestWrapper MyHttpServletRequest = new MyHttpServletRequestWrapper((HttpServletRequest) request);
		MyHttpServletRequest.setParameter("age", "50");
		chain.doFilter(MyHttpServletRequest, response);
	}
}
